
function random(max,min){
    return Math.floor(Math.random()*(max-min+1)+min)
}
setInterval(function(){
    var imgObj=document.createElement('img')
    imgObj.src='./爱心.gif'
    imgObj.width=random(80,60)
    var windowW=window.innerWidth || document.documentElement.clientWidth
    var windowH=window.innerHeight || document.documentElement.clientHeight
    var maxw=windowW-imgObj.offsetWidth
    var maxh=windowH-imgObj.offsetHeight
    imgObj.style.position='fixed'
    imgObj.style.left=random(maxw,0)+'px'
    imgObj.style.top=random(maxh,0)+'px'
    document.body.appendChild(imgObj)
},1000)

document.onclick=function(evt){
    var e=evt || window.event
    var target=e.target || e.srcElement
    if(target.nodeName==='IMG'){
        document.body.removeChild(target)
        num+=10
        if(num>=200) num=200
    }
    
}
var num=200
setInterval(function(){
   var spanObj= document.querySelector('div span')
   num-=2
   spanObj.style.width=num+'px'
   if(num<=0) {
       alert('game over')

    }
},1000)

